package com.muyu.danmo.controller;


import com.muyu.common.core.domain.Result;
import com.muyu.common.core.utils.poi.ExcelUtil;
import com.muyu.common.core.web.controller.BaseController;
import com.muyu.common.core.web.page.TableDataInfo;
import com.muyu.common.log.annotation.Log;
import com.muyu.common.log.enums.BusinessType;
import com.muyu.danmo.domain.DanmoInformationLevel;
import com.muyu.danmo.service.IDanmoInformationLevelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 书法家级别Controller
 * 
 * @author yangle
 * @date 2024-11-13
 */
@RestController
@RequestMapping("/danmoInformationLevel")
public class DanmoInformationLevelController extends BaseController
{
    @Autowired
    private IDanmoInformationLevelService danmoInformationLevelService;

    /**
     * 查询书法家级别列表
     */
//    @RequiresPermissions("system:danmoInformationLevel:list")
    @GetMapping("/list")
    public Result<TableDataInfo<DanmoInformationLevel>> list(DanmoInformationLevel danmoInformationLevel)
    {
        startPage();
        List<DanmoInformationLevel> list = danmoInformationLevelService.selectDanmoInformationLevelList(danmoInformationLevel);
        return getDataTable(list);
    }

    /**
     * 导出书法家级别列表
     */
//    @RequiresPermissions("system:danmoInformationLevel:export")
    @Log(title = "书法家级别", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DanmoInformationLevel danmoInformationLevel)
    {
        List<DanmoInformationLevel> list = danmoInformationLevelService.selectDanmoInformationLevelList(danmoInformationLevel);
        ExcelUtil<DanmoInformationLevel> util = new ExcelUtil<DanmoInformationLevel>(DanmoInformationLevel.class);
        util.exportExcel(response, list, "书法家级别数据");
    }

    /**
     * 获取书法家级别详细信息
     */
//    @RequiresPermissions("system:danmoInformationLevel:query")
    @GetMapping(value = "/{levelId}")
    public Result getInfo(@PathVariable("levelId") Long levelId)
    {
        return success(danmoInformationLevelService.selectDanmoInformationLevelByLevelId(levelId));
    }

    /**
     * 新增书法家级别
     */
//    @RequiresPermissions("system:danmoInformationLevel:add")
    @Log(title = "书法家级别", businessType = BusinessType.INSERT)
    @PostMapping
    public Result add(@RequestBody DanmoInformationLevel danmoInformationLevel)
    {
        return toAjax(danmoInformationLevelService.insertDanmoInformationLevel(danmoInformationLevel));
    }

    /**
     * 修改书法家级别
     */
//    @RequiresPermissions("system:danmoInformationLevel:edit")
    @Log(title = "书法家级别", businessType = BusinessType.UPDATE)
    @PutMapping
    public Result edit(@RequestBody DanmoInformationLevel danmoInformationLevel)
    {
        return toAjax(danmoInformationLevelService.updateDanmoInformationLevel(danmoInformationLevel));
    }

    /**
     * 删除书法家级别
     */
//    @RequiresPermissions("system:danmoInformationLevel:remove")
    @Log(title = "书法家级别", businessType = BusinessType.DELETE)
	@DeleteMapping("/{levelIds}")
    public Result remove(@PathVariable Long[] levelIds)
    {
        return toAjax(danmoInformationLevelService.deleteDanmoInformationLevelByLevelIds(levelIds));
    }
}
